#include "logindialog.h"
#include "ui_logindialog.h"
#include <QMessageBox>

LoginDialog::LoginDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::LoginDialog)
{
    ui->setupUi(this);
}

LoginDialog::~LoginDialog()
{
    delete ui;
}

void LoginDialog::on_loginBtn_clicked()
{
    /**
     * 判断用户名和密码是否正确
     * 如果错误则弹出警告对话框
     */
    if (ui->usrLineEdit->text().trimmed() == tr("demo")
            && ui->pwdLineEdit->text() == tr("demo123456"))
    {
        accept();
    }
    else
    {
        QMessageBox::warning(this, tr("警告！"), tr("用户名或密码错误！"),
                             QMessageBox::Yes);
        ui->pwdLineEdit->clear();
        ui->pwdLineEdit->setFocus();
    }
}

